/*
 *
 * author: fernado
 * create date: 2011-5-17
 */

package iceworld.fernado.file.impl;

import iceworld.fernado.entity.Field;
import iceworld.fernado.resource.SysConfig;

import java.util.List;

public class JavaSaveResource extends SaveResource {

	@Override
	public String getLanguageSuffix() {
		return ".java";
	}

	@Override
	public String generateLanuageFrame(String clazzName, String tableComment,
			List<Field> fields) {
		StringBuilder result = new StringBuilder();
		result.append("package ");
		result.append(SysConfig.getInstance().getValue("namespacename"));
		result.append("{");
		result.append("\r\n");
		
		addTableComment(result, tableComment);
		
		result.append("    ");
		result.append("public class ").append(clazzName);
		result.append(" ");
		result.append("{");
		result.append("\r\n");
		
		for (Field field: fields) {
			generateContent(result, field);
		}

		result.append("    ");
		result.append("}");
		result.append("\r\n");
		result.append("}");
		
		return result.toString();
	}

}
